import { BasicColumn, FormSchema } from "/@/components/Table"
import { rules } from "/@/utils/helper/validator"
import { render } from "/@/utils/common/renderUtils"
import { DescItem } from "/@/components/Description/index"

export const columns: BasicColumn[] = [
  {
    title: "ID",
    width: 120,
    dataIndex: "id",
  },
  {
    title: "名称",
    width: 100,
    dataIndex: "name",
  },
  {
    title: "secretId",
    helpMessage: ["secretId: 用于标识 API 调用者身份，可以简单类比为用户名", "secretKey: 用于验证 API 调用者的身份，可以简单类比为密码"],
    dataIndex: "secretId",
    width: 300,
  },
  // {
  //   title: 'secretKey',
  //   width: 150,
  //   dataIndex: 'secretKey',
  // },

  {
    dataIndex: "status",
    title: "状态",
    width: 60,
    customRender: ({ text }) => {
      let color = "green"
      if (text == "0") color = "#FFCC33"
      if (text == "1") color = "green"

      return render.renderTag(render.renderDict(text, "data_use_status"), color)
    },
  },

  {
    title: "创建时间",
    width: 160,
    dataIndex: "createdAt",
  },

  {
    title: "最后访问时间",
    width: 160,
    dataIndex: "lastAccessTime",
  },
  {
    title: "创建者",
    width: 100,
    dataIndex: "createdBy",
  },
]

export const searchFormSchema: FormSchema[] = [
  {
    field: "name",
    label: "密钥名称",
    component: "Input",
    // colProps: {span: 6},
  },
  // {
  //   label: '系统内置',
  //   field: 'configType',
  //   component: 'JDictSelectTag',
  //   componentProps: {
  //     dictCode:'config_type',
  //     placeholder:'请选择系统内置'
  //   },
  //   // colProps: {span: 6},
  // },
  {
    field: "fieldTime",
    component: "RangePicker",
    label: "创建时间",
    componentProps: {
      valueType: "Date",
    },
    colProps: { span: 12 },
  },
]

export const formSchema: FormSchema[] = [
  {
    field: "id",
    label: "id",
    component: "Input",
    show: false,
  },
  {
    field: "name",
    label: "密钥名称",
    component: "Input",
    required: true,
  },
]

export const formDetailSchema = [
  {
    field: "id",
    label: "应用ID",
  },
  {
    field: "name",
    label: "应用名称",
  },
  {
    field: "appCode",
    label: "应用编码",
  },
  {
    field: "createdAt",
    label: "创建时间",
  },
  {
    field: "createdBy",
    label: "创建者",
  },
  {
    field: "updatedAt",
    label: "更新时间",
  },
  {
    field: "updatedBy",
    label: "更新者",
  },
  {
    field: "remark",
    label: "备注",
    componentProps: {
      autoSize: {
        minRows: 5,
        maxRows: 5,
      },
    },
    span: 1,
  },
]

export const secretFormDetailSchema: DescItem[] = [
  {
    field: "secretId",
    label: "SecretId",
    span: 12,
    labelMinWidth: 60,
  },
  {
    field: "secretKey",
    label: "SecretKey",
    span: 12,
    labelMinWidth: 60,
  },
]
